﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Market.AbstractProduct;

namespace Market.Product
{
    /// <summary>
    /// 满减返利收费
    /// </summary>
    public class CashReturn : CashSuper
    {
        /// <summary>
        /// 满多少
        /// </summary>
        private double moneyCondition = 0.0d;
        /// <summary>
        /// 减多少
        /// </summary>
        private double moneyReturn = 0.0d;

        public CashReturn(double moneyCondition, double moneyReturn)
        {
            this.moneyCondition = moneyCondition;
            this.moneyReturn = moneyReturn;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="money">原价</param>
        /// <returns>最终价钱</returns>
        public override double AcceptCash(double money)
        {
            double result = money;

            if (money >= moneyCondition)
                result = money - (Math.Floor(money / moneyCondition) * moneyReturn);

            return result;
        }
    }
}
